<?php

namespace Pay\Service\Common;

class Randstr
{
    const HUMAN = '12345678ABCEFGHKMNPQRSUVWXYZabcdefhkmnpqsuvwxyz';
    public static function orderNumber()
    {
        $val = md5(uniqid(rand(1, 99999999), true));
        $val = substr($val, 8, 16);
        $ret = time() . $val;
        return $ret;
    }

    public static function human($length = 4)
    {
        return self::rand(self::HUMAN, $length);
    }

    public static function rand($chars, $length)
    {
        $size   = strlen($chars)-1;
        $str    = '';
        for ($i=0; $i<$length; $i++) {
            $str .= $chars[mt_rand(0, $size)];
        }
        return $str;
    }
}
